Fix SETTINGS placement in EXPLAIN AST for FORMAT...SETTINGS syntax#73
Merged
kyleconroy merged 6 commits intomainfrom Dec 28, 2025
Merged
Fix SETTINGS placement in EXPLAIN AST for FORMAT...SETTINGS syntax#73kyleconroy merged 6 commits intomainfrom
kyleconroy merged 6 commits intomainfrom
Conversation
When SETTINGS comes after FORMAT in a query (e.g., "SELECT * FORMAT Null SETTINGS..."), the Set node should only appear at the SelectWithUnionQuery level, not at the SelectQuery level. This matches ClickHouse's EXPLAIN AST behavior. Added SettingsAfterFormat field to SelectQuery AST to track this ordering. This fixes 156+ explain tests that were previously failing.
When SETTINGS comes after FORMAT and there's a FROM clause, Set should appear at both SelectQuery and SelectWithUnionQuery levels. When there's no FROM clause, Set only appears at SelectWithUnionQuery level. This fixes ~87 more explain tests.
When INSERT has a column list (e.g., INSERT INTO t (col1, col2) SELECT ...), the columns are now output as an ExpressionList child node.
Implemented support for: - ADD PROJECTION (parses projection definition with SELECT/ORDER BY/GROUP BY) - DROP PROJECTION - MATERIALIZE PROJECTION - CLEAR PROJECTION Added new AST types: - Projection (with name and select query) - ProjectionSelectQuery (with columns, order by, group by) This fixes 53+ explain tests related to ALTER TABLE projections.
Reverted SETTINGS placement logic to the original behavior: - SETTINGS at SelectQuery level only when there's NO FORMAT - SETTINGS at SelectWithUnionQuery level only when there IS FORMAT The previous changes incorrectly added SettingsAfterFormat tracking which caused tests to fail. The original simpler logic is correct. Also restored all metadata.json files to their original state.
- Updated CLAUDE.md to emphasize running check-explain after changes - Ran check-explain which updated 131 metadata.json files - Tests now properly track which explain tests pass with PROJECTION support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When SETTINGS comes after FORMAT in a query (e.g., "SELECT * FORMAT Null SETTINGS..."),
the Set node should only appear at the SelectWithUnionQuery level, not at the
SelectQuery level. This matches ClickHouse's EXPLAIN AST behavior.
Added SettingsAfterFormat field to SelectQuery AST to track this ordering.
This fixes 156+ explain tests that were previously failing.